import React, { Component } from 'react'
import axios from 'axios'
// https://api.github.com/search/repositories?q=react&sort=stars
export default class App extends Component {
    state = {
        items: []
    }
    render() {
        return (
            <div>
                {
                    this.state.items.map(item => {
                        return (
                            <p key={item.id}>
                                <a href={item.html_url}>{item.full_name}</a>
                            </p>
                        )
                    })
                }
            </div>
        )
    }
    componentDidMount() {
        axios.get(' https://api.github.com/search/repositories', {
            params: {
                q: 'react',
                sort: 'stars'
            }
        }).then(value => {
            console.log(value);
            this.setState({
                items: value.data.items
            })
        }, error => {
            console.log('请求失败', error.message);
        })
    }
}
